﻿namespace linkedin_bot_demo.Common.Converters
{
	using System;
	using System.Windows.Data;
	using System.Globalization;
	using System.Windows.Markup;

	[ValueConversion(typeof(bool), typeof(bool))]
	public class BooleanInvectorValueConverter : MarkupExtension, IValueConverter
	{
		public BooleanInvectorValueConverter() { }


		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			if (value is bool)
				return !(bool)value;

			return value;
		}


		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			if (value is bool)
				return !(bool)value;

			return value;
		}


		public override object ProvideValue(IServiceProvider serviceProvider)
		{
			return this;
		}
	}
}
